package cn.cqsztech.lis;

/**
 * ccmars
 * 2022/3/9
 * 最长递增子序列
 **/
public class Lis {
    /**
     * 返回给定数组最长递增子序列的最大长度
     *
     * @param args
     * @return
     */
    public static int lis(int[] args) {
        if (args == null || args.length == 0) {
            return 0;
        }
        int index = 0;
        int[] temp = new int[args.length];
        temp[0] = args[0];
        for (int i = 0; i < args.length; i++) {
            if (args[i] > temp[i - 1]) {
                temp[i] = args[i];
            }
        }
        return 0;
    }
    /**
     * class Solution {
     *     public int lengthOfLIS(int[] nums) {
     *         if (nums.length == 0) {
     *             return 0;
     *         }
     *         int[] dp = new int[nums.length];
     *         dp[0] = 1;
     *         int maxans = 1;
     *         for (int i = 1; i < nums.length; i++) {
     *             dp[i] = 1;
     *             for (int j = 0; j < i; j++) {
     *                 if (nums[i] > nums[j]) {
     *                     dp[i] = Math.max(dp[i], dp[j] + 1);
     *                 }
     *             }
     *             maxans = Math.max(maxans, dp[i]);
     *         }
     *         return maxans;
     *     }
     */
}
